import axios from 'axios'

import router from '../router'

import Vue from 'vue';
import { Toast } from 'vant';

export const alPath = 'https://zbz-imgs.oss-cn-beijing.aliyuncs.com/';


// const PRODUCT_URL = 'https://www.ccclkj.cn:2040/'
const PRODUCT_URL = 'http://192.168.0.104:2040/'
const MOCK_URL = 'http://192.168.0.104:2040/'
// const MOCK_URL = 'https://www.ccclkj.cn:2040/'

export const baseurl = process.env.NODE_ENV === 'production' ? PRODUCT_URL : MOCK_URL;

export function request(config) {
    Toast.loading({
        message: '加载中...',
        forbidClick: true,
        overlay: true
    });
    const instance = axios.create({
        baseURL: baseurl,
    });
    instance.interceptors.request.use(config => {
        Toast.clear()
        return config
    }, err => {
        console.log(err)
    })
    instance.interceptors.response.use(res => {

        return res.data
    }, err => {
        console.log(err)
    })

    return instance(config)
}